import re
import html

def extract_first_js_decode(content):
    """提取文件中的第一个JsDecode内容"""
    try:
        # 匹配第一个 content_noencode: JsDecode('...')
        pattern = r"content_noencode:\s*JsDecode\('([^']+)'\)"
        match = re.search(pattern, content)
        
        if match:
            encoded_content = match.group(1)
            
            # 解码
            def decode_js(text):
                decoded = re.sub(r'\\x([0-9a-fA-F]{2})', lambda m: chr(int(m.group(1), 16)), text)
                return html.unescape(decoded)
            
            decoded_html = decode_js(encoded_content)
            pure_text = re.sub(r'<[^>]+>', '', decoded_html)
            pure_text = re.sub(r'\s+', ' ', pure_text).strip()
            
            print("找到并解码的内容:")
            print("=" * 50)
            print("纯文本:")
            print(pure_text)
            
            return pure_text
        else:
            print("未找到 content_noencode: JsDecode(...) 内容")
            return None
            
    except Exception as e:
        print(f"错误: {e}")
        return None

# 使用
